<template>
  <div class="thumbs-gallery">
    <div class="main-img">
      <img :src="items[current].img" :alt="items[current].title || ''" />
    </div>
    <div class="thumbs-row">
      <div v-for="(item, idx) in items" :key="idx" class="thumb" :class="{ active: idx === current }"
        @click="current = idx">
        <img :src="item.img" :alt="item.title || ''" />
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
const props = defineProps({
  items: { type: Array, required: true },
})
const current = ref(0)
</script>

<style lang="scss" scoped>
.thumbs-gallery {
  width: 600px;
  margin: 0 auto;

  .main-img {
    width: 100%;
    height: 320px;
    border-radius: 18px;
    overflow: hidden;

    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      border-radius: 18px;
      box-shadow: 0 4px 24px #e0e7ff;
    }
  }

  .thumbs-row {
    display: flex;
    gap: 12px;
    margin-top: 18px;
    justify-content: center;

    .thumb {
      width: 80px;
      height: 60px;
      border-radius: 8px;
      overflow: hidden;
      cursor: pointer;
      border: 2px solid transparent;

      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 8px;
      }

      &.active {
        border-color: #6366f1;
        box-shadow: 0 2px 12px #6366f1;
      }
    }
  }
}
</style>